package com.yequan.file.delete;

import com.yequan.thread.threadpool.mythreadpoolmanager.CustomThreadPoolManager;
import com.yequan.thread.threadpool.mythreadpoolmanager.ThreadPoolManagerFactory;

import java.io.File;
import java.util.Collections;
import java.util.List;
import java.util.Stack;

/**
 * @author yequan
 * @date 2019/12/21
 */
public class ConcurrentDeleteFile {

    public static void main(String[] args) {
        CustomThreadPoolManager threadPoolManager = ThreadPoolManagerFactory.newIoIntensiveThreadPoolManager();
        File file = new File("E:\\ceshi\\1\\fltresult3");
        DelsOfBetter.filesToStack(file);
        Stack<File> fileStack = DelsOfBetter.getFileStack();
        List<File> files = fileStack.subList(0, fileStack.size());
        Collections.reverse(files);
        System.out.println("--------------------------------------------------------");
        for (File f : files) {
            threadPoolManager.executeTask(new DeleteFileTask(f));
        }
    }

}
